package org.example.reactor;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Arrays;
import java.util.stream.Stream;

public class RactorDemo {

    public static void main(String[] args) {
        //Mono的创建方式
        Mono.empty().subscribe(System.out::println);

        Mono.just("hello mono").subscribe(System.out::println);

        //Flux创建方式 0-n元素排列
        Flux.just(1,2,3,4,5,6).subscribe(System.out::println);
        //通过迭代器创建
        Flux.fromIterable(Arrays.asList("a","b","c","d","e")).subscribe(System.out::println);
        //通过数组创建
        Flux.fromArray(new String[]{"a1","b1","c1","d1","e1"}).subscribe(System.out::println);

        //通过流创建
        Flux.fromStream(Stream.of(1,2,3,4,5,6,7,8,9,10)).subscribe(System.out::println);

    }
}
